package haizhi.fruitmall.action;

import haizhi.fruitmall.pojo.form.GoodsCommentForm;
import haizhi.fruitmall.pojo.view.ResultView;
import haizhi.fruitmall.service.DetailService;
import haizhi.fruitmall.util.ResultUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Date: 2017/12/24 19:41
 * @Author: Richard Zane
 */

@Slf4j
@Controller
@RequestMapping("/detail")
public class DetailController {

    @Autowired
    private DetailService detailService;

    @RequestMapping(value = "/getParam",method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public ResultView getParam(@RequestParam(value = "unitId")Long unitId){ return ResultUtil.getSuccess(detailService.getParam(unitId));
    }

    @RequestMapping(value = "/getHead",method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public ResultView getall(@RequestParam(value = "goodsId")Long goodsId){ return ResultUtil.getSuccess(detailService.getHead(goodsId));
    }

    @RequestMapping(value = "/getTail",method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public ResultView getall(GoodsCommentForm form){
        return ResultUtil.getSuccess(detailService.getTail(form));
    }

}
